package com.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
/*
 * 此监听器在项目启动的时候会自动运行contextInitialized, servlet/filter/listener必须配置web.xml
 * */
public class InitDataServletContextListener implements ServletContextListener {

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("---contextDestroyed---");
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		System.out.println("---contextInitialized---");
		String path=event.getServletContext().getRealPath("/");
		System.out.println("path:" + path);
		// 吧当前项目的路径配置到System系统类
		System.setProperty("log4j.path", path);
	}

}
